package com.zxw.cloud.gateway.ab;

import com.netflix.loadbalancer.AbstractServerPredicate;
import com.netflix.loadbalancer.PredicateKey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.alibaba.nacos.ribbon.NacosServer;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;

/**
 *
 * @author zouxw
 */
@Slf4j
public abstract class DiscoveryEnabledPredicate extends AbstractServerPredicate {


    @Override
    public boolean apply(@Nullable PredicateKey input) {

        return input != null
                && input.getServer() instanceof NacosServer
                && apply((NacosServer) input.getServer());
    }

    protected abstract boolean apply(NacosServer server);
}